<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button onclick="but1()">开始</button>
  <button onclick="but2()">结束</button>
  <p></p>
  <script>
    var arr = ['张三', '李四', '王五', '赵六', '刘七']
    function but1() {
      setInterval(but1, 500)
      var res = arr[Math.floor((Math.random() * arr.length))]
      document.querySelector('p').innerText = res
    }
    function but2() {
      clearInterval(but1)
    }
  </script>
</body>

</html>